package com.han.demo.controller;

import com.han.demo.task.AsyncTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hanjl
 * @Description TODO
 * @ClassName AsyncController
 * @createTime 2021/12/2 9:33
 */
@RestController
@RequestMapping("/async")
@Slf4j
public class AsyncController {

    @Autowired
    private AsyncTask asyncTask;

    @RequestMapping("/task")
    public void task() throws InterruptedException{
        long start = System.currentTimeMillis();
        asyncTask.task1();
        asyncTask.task2();
        Thread.sleep(1000);

        long end = System.currentTimeMillis();
        log.info("main cost {} ms",end - start);
    }
}
